/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
/**
 * @version center.h 0.0.1
 * @package Comoro
 * @author Dr.NP <np@bsgroup.org>
 * 
 * Center server main header
 */

#include <event.h>

// Constants
#define DEFAULT_CENTER_SRV_PORT						65001
#define BASE_BUFFER_SIZE								16384
#define GLOBAL_CLIENT_POOL_BASE_SIZE				16384
#define BASE_CLIENT_BASE_SIZE						32

// Structs
struct global_client_item
{
	int base_id;
	int client_id;
};

struct base_server_info
{
	int base_id;
	unsigned long base_addr;
	int base_port;
	char *base_version;
	unsigned long start_time;
	int current_conn;
	int max_conn;
	unsigned long memory_usage;
	unsigned long package_read;
	unsigned long package_send;
};

/* BEGIN OF FUNCTION DEFINE */
int center_init										();
unsigned long center_init_time						();
void center_on_read									(int, void *, unsigned int);
void center_on_close									(int);
struct global_client_item * center_get_base_info	(int);
int center_process_command							(int, int, void *, int);
int center_special_command							(int, unsigned int, unsigned int);
int center_get_free_global_id						();
int center_store_base_info							(int, char *);
struct base_server_info * center_fetch_base_info	(int);

int center_add_client								(int, int);
int center_remove_client								(int, int);

int center_count_client								();
int center_count_regon								();
int center_count_regoff								();
/* END OF FUNCTION DEFINE */
